home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_065 / menubuilder / do_arguments.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  50 lines

  1. #include "exec/types.h"
  2. extern int Flgs[26];
  3.  
  4. extern int Enable_Abort;  /* Flgs[2] (-c) will set to non zero */
  5.                           /* to enable checks for abort        */
  6. Do_Arguments(count,strings)
  7.   int count;
  8.   char *strings[];
  9.   {
  10.   register int loop;
  11.   register char *ptr;
  12.   int  c;
  13.  
  14.   if ( count == 2 && *strings[1] == '?' )
  15.     {
  16.     printf(" Usage is: %s [-option ... -option]\n",strings[0]);
  17.     }
  18.   else
  19.     {
  20.     for(loop=0; loop < 26; loop++) Flgs[loop] = FALSE;
  21.     while ( --count > 0 )                       
  22.       {
  23.       ptr = *++strings;
  24.       if ( *ptr++ == '-' )
  25.         {
  26.         c = toupper(*ptr) - 'A' ;  /* get an index 0 to 25 */
  27.         if ( c >= 0 && c <= 25 )
  28.           {
  29.           Flgs[c] = TRUE;
  30.           }
  31.         else
  32.           {
  33.           printf(" %s has an invalid option: %s\n",strings[0],ptr);
  34.           };
  35.         };
  36.       };
  37.     };
  38.   if( Flgs[3] )   /* if -d requested show selected options */
  39.     for ( c = 0; c < 26; c++)
  40.       if ( Flgs[c] ) printf(" Option %d is on\n",c);
  41.   if( Flgs[2] )
  42.     {
  43.     Enable_Abort = 0;  /* no abort on control-c unless user does it */
  44.     }
  45.   else
  46.     {
  47.     Enable_Abort = 1;  /* abort on control-c */
  48.     };
  49.   }
  50.